(defun move-tab()
  (interactive)
  (setq omark (mark t))
  (setq qmark (point))

  (goto-char omark)
  (setq lineOne (line-number-at-pos))
  (goto-char qmark)
  (setq lineTwo (line-number-at-pos))


  (goto-char omark)
  (while (< (line-number-at-pos) lineTwo)
    (move-beginning-of-line 1)
    (insert "\t")
    (next-line)
    (move-beginning-of-line 1)
    )
  (move-beginning-of-line 1)
  (insert "        ")
  (move-end-of-line 1)
  )

(defun move-tab-previous()
  (interactive)
  (setq omark (mark t))
  (setq qmark (point))

  (goto-char omark)
  (setq lineOne (line-number-at-pos))
  (goto-char qmark)
  (setq lineTwo (line-number-at-pos))
  
  (while (< (line-number-at-pos) lineTwo)    
    (move-beginning-of-line 1)
;    (replace-regexp "\\t" "        " nil tBegin tEnd)
;    (goto-char tBegin)
    (delete-char 8)
    (next-line)
    (move-beginning-of-line 1)
    )

    (move-beginning-of-line 1)
    (delete-char 8)
    (move-end-of-line 1)
  )


(defun move-tab-with-token()
  (interactive)
  (setq token (read-from-minibuffer "Token:"))
  (setq omark (mark t))
  (setq qmark (point))

  (goto-char omark)
  (setq lineOne (line-number-at-pos))
  (goto-char qmark)
  (setq lineTwo (line-number-at-pos))


  (goto-char omark)
  (while (< (line-number-at-pos) lineTwo)
    (move-beginning-of-line 1)
    (insert token)
    (move-beginning-of-line 1)    
    (next-line)
    )
  (move-beginning-of-line 1)
  (insert token)
  (move-end-of-line 1)
  )
;region start

;(replace-regexp "^a$" "b" nil 0 1000)
;(substring "abc" 0 1)

;region end

;(delete-char 8 nil)
        (move-beginning-of-line 1)    
        (next-line)

(setq abc
      '("switch"
        "case"
        "main"
        )
      )

(length abc)



(defun main-complete()
  (interactive)
  ;get token with about to expand
  (setq sPoint (point))
  (backward-word)
  (setq ePoint (point))
  (setq temp (buffer-substring-no-properties ePoint sPoint))
  (print temp)
  (setq tempLength (length temp))
  (print tempLength)

  (setq flags 0)
  (setq endFlags (length abc))
  (switch-to-buffer "*main-complete")
  (erase-buffer)
  (while (< flags endFlags)
    (setq selectItem (nth flags abc))
    (print selectItem)
    (setq whileString (substring selectItem 0 tempLength))
    (print whileString)
    (if (string= temp whileString)
        (cond ((print "insert")
               (print selectItem)
               (insert selectItem)
               (move-end-of-line nil)
               (newline-and-indent)))
      )
    (setq flags (+ flags 1))
    )
  )

(nth 2 abc)

(setq temp (buffer-substring-no-properties 1 5))
(print temp)

(buffer-string)

(current-word)

(backward-word)



;-------------------


(setq abc (buffer-substring-no-properties (point) (+ (point) 1)))

(goto-char (point-min))

(skip-chars-forward " ")  abc 



(setq first-letter (buffer-substring-no-properties (point) (+ (point) 1)))a

(string< first-letter "a")

(string-match "[a-zA-Z]" "a")

(setq sql-keyword '("if"
                   "select"
                   "from"
                   "where"
                   "join"
                   "and"
                   "on"
                   "left"
                   "outer"
                   "declare"
                   "go"
                   "order"
                   "by"
                   ))

(cdr nil)

(assoc "if" sql-keyword)
(string-match "@" "@")

(setq temp-table sql-keyword)

(defvar current-char "")

(defun get-current-char()
  (buffer-substring-no-properties (point) (1+ (point)))
  )

(defun sql-compare-word()
  (setq start-point (point))
  (forward-word 1)
  (while (string= "_" (get-current-char))
    (forward-word 1)
    )
  (setq end-point (point))
  (setq keyword-maybe (downcase (buffer-substring-no-properties start-point end-point)))
  (print keyword-maybe)
  (setq temp-table sql-keyword)
  (while temp-table
    (if (string= keyword-maybe (car temp-table))
        (progn (goto-char start-point)
               (upcase-word 1)
               (setq temp-table nil)
               )
        )
    (setq temp-table (cdr temp-table))
    )
  )


(defun sql-upcase-keyword()
  (interactive)
  (goto-char (point-min))
  (while (< (point) (point-max))
    (skip-chars-forward " ")
    (setq first-letter (get-current-char))
    (cond ((string-match "[a-zA-Z]" first-letter)
           (sql-compare-word))
          
          ((string-match "@" first-letter)
           (forward-word 1))

          ((string-match "'" first-letter)
           (print first-letter)
           (forward-char 1)
           (print (get-current-char))
           (skip-chars-forward "^'")
           (print (= (point) (point-max)))
           (forward-char 1))
          ((string-match "\"" first-letter)
           (forward-char 1)           
           (skip-chars-forward "^\"")
           (forward-char 1)
          )
          ((string-match "-" first-letter)
           (forward-char 1)
           (setq second-letter (get-current-char))
           (if (string-match "-" second-letter)
               (move-end-of-line 1))
           )
          (t (forward-char 1))
          )
    )
  )


;-----------------------------------

(re-search-forward "*/" nil t)    abc*/